package com.training.bt.config;

import com.training.bt.tracker.CustomTracker;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import java.net.InetSocketAddress;
import java.io.IOException;

@Configuration
public class TrackerConfig {

    @Value("${app.constants.ip}")
    private String ip;

    @Bean
    public CustomTracker customTracker() throws IOException {
        // 绑定到所有网络接口，端口使用默认的 6969
        InetSocketAddress address = new InetSocketAddress(ip, CustomTracker.DEFAULT_TRACKER_PORT);
        return new CustomTracker(address);
    }
}